package com.caesar.exer2;

import java.util.Collection;
import java.util.HashMap;
import java.util.Scanner;

/**
 * @author caesar
 * @date 2025/7/18
 * @Description:
 * @apiNote
 */
public class exer1 {
    public static void main(String[] args) {
        HashMap<String,Integer> map = new HashMap<>();
        Scanner input = new Scanner(System.in);
        System.out.print("请输入学生人数：");
        int count = input.nextInt();

        for (int i = 1; i <= count; i++) {
            System.out.print("请输入第"+i+"个学生的姓名：");
            String name = input.next();

            System.out.print("请输入第"+i+"个学生的成绩：");
            int score = input.nextInt();

            map.put(name,score);
        }
        System.out.println(map);
        Collection<Integer> values = map.values();
        double sum = 0;
        for (Integer value : values) {
            sum += value;
        }
        System.out.println("平均分：" + sum/ map.size());

        System.out.print("请输入你要查询成绩的学生姓名：");
        String find = input.next();

        Integer score = map.get(find);
        if(score==null){
            System.out.println(find+"未参加考试，没有成绩！");
        }else{
            System.out.println(find +"考了" + score +"分");
        }
        input.close();
    }
}
